package kata09.discount;

import java.math.BigDecimal;

/**
 *  买3赠1
 */
public class CGoodsDiscount implements IGoodsDiscountStrategy {
    @Override
    public BigDecimal getGoodsDiscountPrice(int buyNumber, BigDecimal sourcePrice) {
        if(buyNumber >= 3){
            int discountPriceNumber = buyNumber / 3;
            int sourcePriceNumber = buyNumber - discountPriceNumber;
            return sourcePrice.multiply(new BigDecimal(sourcePriceNumber));
        }
        return sourcePrice.multiply(new BigDecimal(buyNumber));
    }
}
